package com.ctshk.sapp.starvip.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.rpc.starvip.dto.UserMemberBasicInformationDTO;
import com.ctshk.rpc.starvip.req.TransactionIntegralCommonReq;
import com.ctshk.rpc.starvip.req.TransactionIntegralReq;
import com.ctshk.rpc.starvip.req.UserMemberBasicInformationReq;
import com.ctshk.rpc.starvip.service.IStarVipBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @BelongsProject: ctshk-cloud
 * @BelongsPackage: com.ctshk.sapp.starvip.controller
 * @Author: hef
 * @CreateTime: 2021-04-12 15:47
 * @Description: 描述
 */
@RestController
@RequestMapping(value = "/business")
@Api(value = "星赏会用户相关", tags = "星赏会用户相关")
public class StarVipbusinessController {
    @DubboReference
    private IStarVipBusinessService businessService;

    @PostMapping("/member/search")
    @ApiOperation(value = "获取会员基本信息", notes = "获取会员基本信息")
    @OperationLogAnnotation(operType = OperationLogType.QUERY, operTitle = "获取会员基本信息", operDesc = "获取会员基本信息")
    public Result<UserMemberBasicInformationDTO> getUserMemberBasicInformation(@RequestBody UserMemberBasicInformationReq req) {
        return businessService.getUserMemberBasicInformation(req);
    }

    @PostMapping("/transactionIntegral")
    @ApiOperation(value = "积分交易", notes = "积分交易")
    @OperationLogAnnotation(operType = OperationLogType.UPDATE, operTitle = "积分交易", operDesc = "积分交易")
    public Result transactionIntegral(@RequestBody TransactionIntegralReq req){
        return businessService.transactionIntegral(req);
    }

    @GetMapping("/hkd/{point}")
    @ApiOperation(value = "积分兑换港币", notes = "积分兑换港币")
    @OperationLogAnnotation(operType = OperationLogType.QUERY, operTitle = "积分兑换港币", operDesc = "积分兑换港币")
    public Result getHKD(@PathVariable Integer point) {
        return Result.success(businessService.getHkd(point));
    }

    @PostMapping("/transactionIntegralCommon")
    @ApiOperation(value = "测试C端积分交易", notes = "测试C端积分交易")
    @OperationLogAnnotation(operType = OperationLogType.UPDATE, operTitle = "测试C端积分交易", operDesc = "测试C端积分交易")
    public Result transactionIntegralCommon(@RequestBody @Valid TransactionIntegralCommonReq req){
        return businessService.transactionIntegralCommon(req);
    }

    @PostMapping("/cancelTransactionIntegralCommon")
    @ApiOperation(value = "测试C端取消积分交易", notes = "测试C端取消积分交易")
    @OperationLogAnnotation(operType = OperationLogType.UPDATE, operTitle = "测试C端取消积分交易", operDesc = "测试C端取消积分交易")
    public Result cancelTransactionIntegralCommon(@RequestBody @Valid TransactionIntegralCommonReq req){
        return businessService.cancelTransactionIntegralCommon(req);
    }

}
